﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EasyBuy.BLL;
using EasyBuy.Model;

namespace EasyBuy.WEB
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text.Trim().Length == 0 || txtUserPwd.Text.Trim().Length == 0)
            {
                lblError.Text = "用户名或者密码不能为空!";
                lblError.Visible = true;
                return;
            }
            lblError.Visible = false;
            UserManager userManager = new UserManager();
            User user = userManager.Login(txtUserName.Text.Trim(), txtUserPwd.Text.Trim());
            if (user != null)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('登录成功!')", true);
            }
            else
            {
                txtUserPwd.Text = "";
                txtUserName.Text = "";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('登录失败!')", true);
            }
        }

    }
}